# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Stefan Kirrmann <stefan.kirrmann at gmail dot com>

pkgname=open-iscsi
pkgver=2.1.8
pkgrel=2
pkgdesc='iSCSI userland tools'
arch=('loong64' 'x86_64')
url='https://www.open-iscsi.com/'
license=('GPL')
makedepends=('systemd' 'meson')
depends=('systemd-libs' 'util-linux-libs' 'kmod' 'openssl' 'open-isns')
install=$pkgname.install
backup=('etc/iscsi/iscsid.conf'
	'etc/iscsi/initiatorname.iscsi')
options=('docs')
source=("$pkgname-$pkgver.tar.gz::https://github.com/open-iscsi/open-iscsi/archive/$pkgver.tar.gz")
sha256sums=('9565bdf6b68b223e1e0d455d9a04d7536724a3f5b5a254e9398d06b2a0c6b6d2')

build() {
  cd "$srcdir"/${pkgname}-${pkgver}

  arch-meson -D rulesdir="/usr/lib/udev/rules.d build" -Discsi_sbindir=/usr/bin build
  meson compile -C build
}

package() {
  cd "$srcdir"/${pkgname}-${pkgver}

  meson install -C build --destdir "$pkgdir"

  install -D -m0644 "$srcdir"/${pkgname}-${pkgver}/etc/iscsid.conf "$pkgdir"/etc/iscsi
  echo -n > "$pkgdir"/etc/iscsi/initiatorname.iscsi

  # copy docs
  mkdir -p "$pkgdir"/usr/share/doc/${pkgname}
  install -m0644 Changelog "$pkgdir"/usr/share/doc/${pkgname}/
  install -m0644 README "$pkgdir"/usr/share/doc/${pkgname}/
}
